package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Them;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.ThemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/23 16:11
 */
@CrossOrigin
@RestController
@Api(tags = "番剧国创等")
@RequestMapping("/them")
public class ThemController {

    @Autowired
    private ThemService themService;

    @ApiOperation("添加番剧或影视，videoSetId,smallCover,verticalCover,updateDay必须")
    @PostMapping("/add")
    public R<Void> add(Them them) {
        return themService.add(them);
    }

//    @ApiOperation("转发番剧,ThemId,转发评论必须")
//    @GetMapping("/forward")
//    public R<Void> forward(Integer id, String content, HttpSession session){
//        return themService.forward(id,content,session);
//    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return themService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(Them them) {
        return themService.update(them);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Them>> page(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "10") Integer size) {
        return themService.page(page, size);
    }

    @ApiOperation("根据更新时间获取番剧0-6  周1到周日  typeId  类型Id")
    @GetMapping("/getUpdate")
    public R<List<Them>> getUpdate(Integer updateDay, Integer typeId) {
        return themService.getUpdate(updateDay, typeId);
    }

    @ApiOperation("获取番剧排名 需要类型 typeId  finish  是否完结  默认获取全部")
    @GetMapping("/getRank")
    public R<List<Them>> getRank(@RequestParam(defaultValue = "10") Integer size,
                                 @RequestParam(required = false) Boolean finish, Integer typeId) {
        return themService.getRank(size, typeId,finish);
    }

    @ApiOperation("随机获取番剧 需要类型 typeId  finish  是否完结  默认获取全部")
    @GetMapping("/getRandom")
    public R<List<Them>> getRandom(@RequestParam(defaultValue = "10") Integer size,
                                   @RequestParam(required = false) Boolean finish, Integer typeId){
        return themService.getRandom(size,finish,typeId);
    }

    @ApiOperation("获取详细的番剧信息")
    @GetMapping("/getThem")
    public R<Them> getThem(Integer id){
        return themService.getThem(id);
    }

}
